﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DBUtility;

public partial class Control_ProductInfo_Top : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ControlDataInit();
    }


    #region ControlDataInit
    protected void ControlDataInit()
    {
        if (Request.QueryString["ProductID"] == null)
        {
            Response.Redirect("Product.aspx");
        }
        else
        {
            string ProductID = Request.QueryString["ProductID"].ToString();

            string SQLstr = "SELECT Product.*, ProductClass.PC_Title FROM (Product INNER JOIN ";
            SQLstr += "ProductClass ON Product.Product_ClassID = ProductClass.PC_ID) WHERE (Product.Product_ID = " + ProductID + ")";

            DataTable DT_ProductInfo = AccHelper.GetDataTable(SQLstr);

            IMG_ProductImage.ImageUrl = FormatImage(DT_ProductInfo.Rows[0]["Product_Thumbnail"]);
            LB_DateTime.Text = DT_ProductInfo.Rows[0]["Product_DateTime"].ToString();
            LB_ProductClass.Text = DT_ProductInfo.Rows[0]["PC_Title"].ToString();
            LB_Title.Text = DT_ProductInfo.Rows[0]["Product_Title"].ToString();
            LB_Content.Text = DT_ProductInfo.Rows[0]["Product_Content"].ToString();
            LB_Intro.Text = DT_ProductInfo.Rows[0]["Product_Intro"].ToString();
        }
    }
    #endregion


    #region 产品图片 [格式化]
    protected string FormatImage(object _Image)
    {
        string ImageURL = Convert.ToString(_Image);

        if (ImageURL == "")
        {
            return "~/Manageweb/images/null.jpg";
        }
        else
        {
            return "~/UploadImage/" + ImageURL;
        }
    }
    #endregion
}
